package com.sc.gateway.filter;


import com.sc.gateway.dto.ResultDTO;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@Component
public class ExceptionFilter {
    /**
     * 全局异常捕捉处理
     * @param e
     * @return
     */
    @ResponseBody
    @ExceptionHandler(value = Exception.class)
    public ResultDTO errorHandler(Exception e) {
        e.printStackTrace();
        return ResultDTO.err(e.getMessage());
    }
}
